package com.dy.drp.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dy.drp.dto.BuyinfoDto;
import com.dy.drp.entity.Buyinfo;
import com.dy.drp.service.IBuyinfoService;
import com.dy.drp.service.IBuyshorttimeService;
import com.dy.drp.util.PageUtil;
import com.dy.drp.util.SelectUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dy
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/buyinfo")
@Api(tags = "采购信息查询")
public class BuyinfoController{
    @Autowired
    private IBuyinfoService buyinfoService;

    @GetMapping("/selectBuyInfo/{pageNum}/{pageSize}")
    @ApiOperation("查询单页采购信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pageNum",value="当前页码"),
            @ApiImplicitParam(name="pageSize",value="页面条数")
    })
    public PageUtil<BuyinfoDto> selectBuyInfo(@PathVariable("pageNum")Integer pageNum,
                                       @PathVariable("pageSize")Integer pageSize){
        PageUtil<BuyinfoDto> pageUtil = new PageUtil<>();
        pageUtil.setPageNum(pageNum);
        pageUtil.setPageSize(pageSize);
        return buyinfoService.selectOnePageBuyinfo(pageUtil);
    }

    @PostMapping("/selectByProviderAndTime")
    @ApiOperation("查询采购信息")
    public PageUtil<BuyinfoDto> selectByProviderAndTime(SelectUtil selectUtil){
        return buyinfoService.selectOnePageBuyinfoByInfo(selectUtil);
    }

    @GetMapping("/selectOneBuyById/{buyId}")
    @ApiOperation("查询采购详情")
    @ApiImplicitParam(name="buyId",value = "采购ID")
    public BuyinfoDto selectOneBuyById(@PathVariable("buyId")Long buyId){
        return buyinfoService.selectOneBuyById(buyId);
    }
}
